package com.company.java20.test14;

import java.util.function.Function;
import java.util.function.Predicate;

@FunctionalInterface
interface Interface1{
    int doubleNum(int i);
}

@FunctionalInterface
interface interface2{
    int doubleNum2(int i);
    default int add(int i, int j){
        return i+j;
    }
}

class MyMoney{
    private final int m;

    public MyMoney(int m){
        this.m = m;
    }

    public void print(Function<Integer, Integer> moneyFar){
        System.out.println(moneyFar.apply(m));
    }

    public void print(Predicate<Integer> predicate){
        System.out.println(predicate.equals(true));
    }

}


public class LambdaDemo1 {

     public static void main(String[] args){
         Interface1 i1 = i -> i+2;

         Interface1 s = a->2;
         System.out.println(s.doubleNum(1));

         interface2 a = r->r*2;
         int o = a.doubleNum2(2);
         interface2 b = a1->2;
         b.add(1, 3);

         Function<Integer, Integer> i2 = m->m*2;

         new MyMoney(200).print(i2.andThen(m->m*2));
         Predicate<Integer> a1 = a2->a2>2;

         new MyMoney(200).print(a1);
     }
}
